<!DOCTYPE HTML>
<html lang="zh">
<meta charset="utf-8">
<head>
    <link href="/aityWeb/static/favicon.ico" rel="stylesheet"/>
    <link href="/aityWeb/static/css/font-awesome.css" rel="stylesheet"/>

    <style type="text/css">
        .nav > li:hover .dropdown-menu {display: block;}
    </style>

    <link href="/aityWeb/static/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/aityWeb/static/css/font-awesome.css" rel="stylesheet"/>
    <!-- bootstrap-table 表格插件样式 -->
    <link href="/aityWeb/static/ajax/libs/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"/>
    <link href="/aityWeb/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.css" rel="stylesheet"/>
    <link href="/aityWeb/static/css/animate.css" rel="stylesheet"/>
    <link href="/aityWeb/static/css/style.css" rel="stylesheet"/>
    <link href="/aityWeb/static/css/checkbox.css" rel="stylesheet"/>
    <link href="/aityWeb/static/ajax/libs/select/select2.css" rel="stylesheet"/>
    <link href="/aityWeb/static/galaxy/css/ry-ui.css" rel="stylesheet"/>


</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-info" style="padding-top: 10px;">
            <ul class="breadcrumb" style="font-size: 16px;background-color: #f3f3f3;padding: 5px 10px;color: #337ab7;">
                <li><i class="fa fa-home" aria-hidden="true"></i>&nbsp;&nbsp;<a href="#">首页</a></li>
                <li class="active"><a href="#">结算模板管理</a></li>
            </ul>
            <div class="btn-group hidden-xs" id="toolbar" role="group">
                <button  id="load_create_item_modal_btn" type="button" class="btn btn-primary" onclick="add();">
                    <span class="glyphicon glyphicon-plus"></span>
                    新建模板
                </button>

            </div>
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div class="modal fade" id="add_item_modal">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
							<h4 class="modal-title">编辑结算模板</h4>
						</div>
						<div class="modal-body">
							<form class="form-horizontal" id="add_item_form">
								<div id='examinesCode' style="display: none;" class="form-group">
									<div class="form-group">
										<label for="num" class="col-sm-3 control-label">场馆id</label>
										<div class="col-sm-7">
											<input readonly="readonly" name="shopid" id="shopid" type="text" class="form-control" data-valid="required">
											<p class="text-warning" id="num_tips"></p>
										</div>
									</div>
								</div>
								<input name="id" id="couponsId" style="display: none;" />
										<div class="form-group">
									<label for="num" class="col-sm-3 control-label">结算模板名</label>
									<div class="col-sm-7">
										<input name="name" id="name" type="text" class="form-control" placeholder="请填写兑换券发放数量" data-valid="required" data-tips="请填写优惠数量">
										<p class="text-warning" id="num_tips"></p>
									</div>
								</div>
								<div class="form-group">
									<label for="timeFrom" class="col-sm-3 control-label">起始时间</label>
									<div class="col-sm-7">
										<input name="timeFrom" type="date" id="timeFrom" class="form-control cp" placeholder="请填写起始时间" data-valid="required" data-tips="请填写起始时间">
									</div>
								</div>
								<div class="form-group">
									<label for="timeTo" class="col-sm-3 control-label">结束时间</label>
									<div class="col-sm-7">
										<input name="timeTo" type="date" id="timeTo" class="form-control cp" placeholder="请填写结束时间" data-valid="required" data-tips="请填写结束时间">
									</div>
								</div>
								<!--<div class="form-group">
									<label for="num" class="col-sm-3 control-label">兑换券名称</label>
									<div class="col-sm-7">
										<input name="name" id="name" type="text" class="form-control" placeholder="请填写兑换券名称" data-valid="required" data-tips="请填写兑换券名称">
										<p class="text-warning" id="num_tips"></p>
									</div>
								</div>-->
									<!--<div class="form-group">
									<label for="num" class="col-sm-3 control-label">原价</label>
									<div class="col-sm-7">
										<input name="initprice" id="initprice" type="text" class="form-control" placeholder="请填写兑换券原价" data-valid="required" data-tips="请填写原价">
										<p class="text-warning" id="num_tips"></p>
									</div>
								</div>
								<div class="form-group">
									<label for="num" class="col-sm-3 control-label">优惠价</label>
									<div class="col-sm-7">
										<input name="price" id="price" type="text" class="form-control" placeholder="请填写兑换券现价" data-valid="required" data-tips="请填写现价">
										<p class="text-warning" id="num_tips"></p>
									</div>
								</div>-->
								
								<div class="form-group">
									<label for="num" class="col-sm-3 control-label">羽毛球数量</label>
									<div class="col-sm-7">
										<input name="num" id="num" type="text" class="form-control" placeholder="请填写羽毛球数量" data-valid="required" data-tips="请填写羽毛球数量">
										<p class="text-warning" id="num_tips"></p>
									</div>
								</div>
								<!--<div id="stdium_bkcount" class="form-group">
									<label for="count" class="col-sm-3 control-label">每人/每日</label>
									<div class="col-sm-7">
										<input name="percount" id="percount" type="text" class="form-control" placeholder="请填写人次/日数" data-valid="required" data-tips="请填写人次/日数">
									</div>
								</div>
								<div id="stdium_bkcount" class="form-group">
									<label for="count" class="col-sm-3 control-label">每日发放</label>
									<div class="col-sm-7">
										<input name="daycount" id="daycount" type="text" class="form-control" placeholder="每日发放" data-valid="required" data-tips="每日发放">
									</div>
								</div>-->
								<div class="form-group">
									<label for="remark" class="col-sm-3 control-label">结算价格</label>
									<div class="col-sm-7">
										<input name="settleSum" id="settleSum" type="text" class="form-control" placeholder="请填写结算金额">
									</div>
								</div>
							</form>
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" id="item_close">关闭</button>
							<button type="button" class="btn btn-primary submit_item_btn" data-method="one" id="item_submit_save">保存</button>
						</div>
					</div>
					<!-- /.modal-content -->
				</div>
				<!-- /.modal-dialog -->
			</div>
	
<script src="/aityWeb/static/js/jquery.min.js"></script>
<script src="/aityWeb/static/js/bootstrap.min.js"></script>
<script src="/aityWeb/static/js/echarts.common.min.js"></script>

<!-- bootstrap-table 表格插件 -->
<script src="/aityWeb/static/ajax/libs/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/aityWeb/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="/aityWeb/static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
<script src="/aityWeb/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js"></script>
<!-- jquery-validate 表单验证插件 -->
<script src="/aityWeb/static/ajax/libs/validate/jquery.validate.min.js"></script>
<script src="/aityWeb/static/ajax/libs/validate/messages_zh.min.js"></script>
<script src="/aityWeb/static/ajax/libs/validate/jquery.validate.extend.js"></script>
<!-- jquery-validate 表单树插件 -->
<script src="/aityWeb/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js"></script>
<!-- jquery-export 表格导出插件 -->
<script src="/aityWeb/static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js"></script>
<script src="/aityWeb/static/ajax/libs/bootstrap-table/extensions/export/tableExport.js"></script>
<!-- 遮罩层 -->
<script src="/aityWeb/static/ajax/libs/blockUI/jquery.blockUI.js"></script>
<script src="/aityWeb/static/ajax/libs/layer/layer.min.js"></script>
<script src="/aityWeb/static/ajax/libs/layui/layui.js"></script>
<script src="/aityWeb/static/galaxy/js/common.js?v=2.3.0"></script>
<script src="/aityWeb/static/galaxy/js/ry-ui.js?v=2.3.0"></script>
	<script type="text/javascript" src="../../../../static/js/app/app.js"></script>
	<script type="text/javascript" src="../../../../static/js/lib/MD5.js"></script>
	<script type="text/javascript" src="../../../../static/js/app/net.js"></script>
<script type="text/javascript" src="../../../../static/js/wxweb/settlement.js"></script>
<script type="text/javascript">
	var re = GetRequest();
	var shop = re['shop'];
    //调试开关
	var debug_switch = true;
    var prefix = '';
      function loadInner(url) {
        window.location.href = "add.html";
      }
   jQuery(document).ready(function() {
        dataTableInit();

   });
   function dataTableInit() {
         $("#bootstrap-table").bootstrapTable({
//          url: "../static/json/info.json",
//          createUrl: prefix + "/add",
//          updateUrl: prefix + "/edit/{id}",
//          removeUrl: prefix + "/remove",
//          search: false,
            modalName: "设备接地箱",
            url: "http://test.dongqil.com/qyd_dongqil/shop/addSettletempitem",
            cache: false,
            method: 'post', 
            sortable: false, //是否启用排序
            pagination: true, //分页
            pageNumber:1,//初始化加载第一页，默认第一页
            pageSize: 10,
            pageList: [5,10, 25, 50],//可供选择的每页的行数（*）
            singleSelect: false,
//          showColumns: true,  //显示下拉框勾选要显示的列
            locale:"zh-US", //表格汉化
            search: false , //显示搜索框
            sidePagination: "server", //服务端处理分页server client
            //【查询设置】
            /* queryParamsType的默认值为 'limit' ,在默认情况下 传给服务端的参数为：offset,limit,sort
             设置为 ''  在这种情况下传给服务器的参数为：pageSize,pageNo */
            queryParamsType:'',
            queryParams: function queryParams(params) {
                     var param = {
                    data:{
                        page: params.pageNumber,
                        rows: params.pageSize,
                        type:"wxselect",
                        shop:parseInt(shop)
                    },
                    checkcode:"",
                    type: 1//0 APP;1 后台
            };
             syslog(JSON.stringify(param));
                return param;
                
               },
               responseHandler: function(res) {
                return {
                    "total": res.data.total,//总页数
                    "rows": res.data.rows   //数据
                 };
               },
				columns: [{
					checkbox: true
				},
                {
                    field : 'id',
                    title : '设备ID'
                },
                    {
                    field : 'name',
                    title : '结算模板名'
                },
                {
                    field : 'timefrom',
                    title : '起始时间'
                },
                {
                    field : 'maxsalenum',
                    title : '优惠数量'
                },
//              {
//                  field : 'price',
//                  title : '原价'
//              },
//              {
//                  field : 'saleprice',
//                  title : '优惠价'
//              },
                    {
                        field : 'settlesum',
                        title : '结算'
                    },
                    {
                        field : 'timeto',
                        title : '有效期'
                    },
                    {
                        field : 'status',
                        title : '审核',
                                      formatter:function (value,row,index) {
                if(row.status == 1){
                    return "未审核";
                }else{
                	return "审核通过";
                }
            }
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a href="#" onclick="edit('+row.id+')"><i class="fa fa-pencil"></i>编辑</a>') ;
                        actions.push('<a href="#" style="margin-left: 10px;" onclick="deletes('+row.id+')"><i class="fa fa-edit"></i>删除</a> ');

                        return actions.join('');
                    }
                }]
        })
       }  
         function add(){
//       		$('[name="id"]').val("");
//	$('[name="shopname"]').val("");
//	$('[name="code"]').val("");
	$('[name="timeFrom"]').val("");
	$('[name="timeTo"]').val("");
	$('[name="num"]').val("");
	$('[name="name"]').val("");
//	$('[name="percount"]').val("");
//	$('[name="name"]').val("");
	$('[name="price"]').val("");
	$('[name="initprice"]').val("");
	$('[name="settleSum"]').val("");
         		$('#add_item_modal').modal('show');
         			$('#item_submit_save').attr('data-type','create');
//      $.loadInner.updateUrl("/aityWeb/view/clubManger/edit.html");
    }

    function  deletes(id) {
							//加载结算详情
							var info = {
								id: id,
								type: "delete"
							};
							doPost("shop/addSettletempitem",info,function(data){
									
								if(data.success){
									alert('删除成功');
									queryTemplate();
								}else if(data.code == 400){
									alert(data.desc);
								}
							});

				
       // $.loadInner.updateUrl("/aityWeb/view/venue/details/venue_detail.html");
        // $.loadInner.updateUrl("/aityWeb/view/venue/details/venue_upload.html");
//      $.loadInner.updateUrl("/aityWeb/view/venue/details/card.html");
    }
    	function syslog(strlog){
		if(debug_switch){
			console.log(strlog);
		}
	}


    function edit(id){
//  	e.preventDefault();
			$('#add_item_modal').modal('show');
			$('#item_submit_save').attr('data-type','edit');
//			var btn1 = document.getElementById('check_code_btn');
//			btn1.style.display = 'none';
//			document.getElementById('code').readOnly = true;
//			$('#examinesCode').slideDown('slow');
			//新增提交数据
			var info = {
				type:"wxselect",
				id: id
			};
			doPost("shop/addSettletempitem", info, function(data) {
				if(data.success) {
					var r = data.data;
					$('[name="id"]').val(r[0].id);
//					$('[name="shopname"]').val(r[0].shopname);
//					$('[name="shopid"]').val(r[0].shop);
//					$('[name="code"]').val(r[0].shopcode);
					$('[name="timeFrom"]').val(r[0].timefrom);
					$('[name="timeTo"]').val(r[0].timeto);
					$('[name="num"]').val(r[0].maxsalenum);
					$('[name="name"]').val(r[0].name);
//					$('[name="percount"]').val(r[0].percount);
//					$('[name="name"]').val(r[0].couponname);
//					$('[name="usedNum"]').val(r[0].usednum);
//					$('[name="remainNum"]').val(r[0].remainnum);
//					$('[name="price"]').val(r[0].saleprice);
//					$('[name="initprice"]').val(r[0].price);
//					$('[name="daycount"]').val(r[0].daycount);
//					$('input[name="couponstype"][value="' + r[0].description + '"]').prop("checked", "checked");
					$('[name="settleSum"]').val(r[0].settlesum);
					
				} else if(data.code == 400) {
					alert(data.desc);
				}
			});
			
//      $.loadInner.updateUrl("/aityWeb/view/venue/detail/settlement/edit.html");
    }
    function GetRequest() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
        	var name = strs[i].split("=")[0];
        	var value = strs[i].split("=")[1];
            //theRequest[name]=unescape(value);
            theRequest[name]=decodeURI(value);
        }
   }
   return theRequest;
};

</script>
</body>
</html>

